﻿(function ($) {
    var methods = {
        init: function (options) {
            this.each(function () {
                var data = $(window).data("scriptManager-data");

                if (!data) {
                    data = {
                        scriptManager: $(this),
                        form: $("#" + options.form)
                    };
                }

                $(window).data("scriptManager-data", data);

                $(this).pageRequestManager();
            });
        },
        destroy: function () {
        }
    };

    $.fn.scriptManager = function (method, options) {
        var settings = $.extend({
            form: ""
        }, options);

        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.scriptManager');
        }
    }
})(jQuery);